package hn.cch.persistence.p6spy;

import com.p6spy.engine.common.P6Util;
import com.p6spy.engine.spy.appender.MessageFormattingStrategy;

public class MyMessageFormattingStrategy implements MessageFormattingStrategy {
    /**
     * @param connectionId  连接ID
     * @param now  当前时间
     * @param elapsed  执行耗时
     * @param category 分类
     * @param prepared 预编译sql脚本
     * @param sql 实际执行的sql脚本
     * @param url 数据库URL
     * @return 格式化后的日志消息
     */
    @Override
    public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
        return "#" + now + " | took " + elapsed + "ms | " + category + " | connection " + connectionId + "| url " + url + "\n" + prepared + "\n" + sql + ";";
    }
}
